package com.ihr360.message.service.impl;

import com.ihr360.message.dao.MessageTemplateDao;
import com.ihr360.message.dto.MessageTemplateDto;
import com.ihr360.message.entity.MessageTemplate;
import com.ihr360.message.service.MessageTemplateService;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;


@Service
public class MessageTemplateServiceImpl implements MessageTemplateService {

    @Autowired
    private MessageTemplateDao messageTemplateDao;


    @Override
    public MessageTemplate getMessageTemplate(int service, String dataDto, int messageType, String local) {
        MessageTemplateDto messageTemplateDto = messageTemplateDao.findByServiceAndDataDtoAndMessageTypeAndLocal(service, dataDto, messageType, local);
        if(messageTemplateDto == null) {
            return null;
        }
        MessageTemplate messageTemplate = new MessageTemplate();
        BeanUtils.copyProperties(messageTemplateDto, messageTemplate);
        return messageTemplate;
    }
}
